package com.ruoyi.web.controller.laiqianba.account;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.db.domain.AccountChannelInfoHis;
import com.ruoyi.account.service.IAccountChannelInfoHisService;
import com.ruoyi.web.wrapper.AccountChannelInfoHisWrapper;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 渠道账户流水Controller
 * 
 * @author ruoyi
 * @date 2023-08-28
 */
@RestController
@RequestMapping("/account/channelInfoHis")
public class AccountChannelInfoHisController extends BaseController
{
    @Autowired
    private IAccountChannelInfoHisService accountChannelInfoHisService;

    /**
     * 查询渠道账户流水列表
     */
    @PreAuthorize("@ss.hasPermi('account:channelInfoHis:list')")
    @GetMapping("/list")
    public TableDataInfo list(AccountChannelInfoHis accountChannelInfoHis)
    {
        startPage();
        List<Map<String, Object>> list = accountChannelInfoHisService.selectAccountChannelInfoHisMapList(accountChannelInfoHis);
        list = new AccountChannelInfoHisWrapper(list).wrap();
        return getDataTable(list);
    }

    /**
     * 导出渠道账户流水列表
     */
    @PreAuthorize("@ss.hasPermi('account:channelInfoHis:export')")
    @Log(title = "渠道账户流水", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AccountChannelInfoHis accountChannelInfoHis)
    {
        List<AccountChannelInfoHis> list = accountChannelInfoHisService.selectAccountChannelInfoHisList(accountChannelInfoHis);
        ExcelUtil<AccountChannelInfoHis> util = new ExcelUtil<AccountChannelInfoHis>(AccountChannelInfoHis.class);
        util.exportExcel(response, list, "渠道账户流水数据");
    }

    /**
     * 获取渠道账户流水详细信息
     */
    @PreAuthorize("@ss.hasPermi('account:channelInfoHis:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(accountChannelInfoHisService.selectAccountChannelInfoHisById(id));
    }

    /**
     * 新增渠道账户流水
     */
    @PreAuthorize("@ss.hasPermi('account:channelInfoHis:add')")
    @Log(title = "渠道账户流水", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AccountChannelInfoHis accountChannelInfoHis)
    {
        return toAjax(accountChannelInfoHisService.insertAccountChannelInfoHis(accountChannelInfoHis));
    }

    /**
     * 修改渠道账户流水
     */
    @PreAuthorize("@ss.hasPermi('account:channelInfoHis:edit')")
    @Log(title = "渠道账户流水", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AccountChannelInfoHis accountChannelInfoHis)
    {
        return toAjax(accountChannelInfoHisService.updateAccountChannelInfoHis(accountChannelInfoHis));
    }

    /**
     * 删除渠道账户流水
     */
    @PreAuthorize("@ss.hasPermi('account:channelInfoHis:remove')")
    @Log(title = "渠道账户流水", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(accountChannelInfoHisService.deleteAccountChannelInfoHisByIds(ids));
    }
}
